package datastructures;

import java.util.StringTokenizer;

public class Interaction {

	private final int interactionArity = 2;
	//snp data
	private int[] mapfileIndex;
	private String[] mode;
	private int[] chromosome;
	private String[] snpRSID;
	private double[] cmdistance;
	private long[] bpdistance;
	
	//other data
	private double[][] expectedCases = new double[2][2];
	private int[][] observedCases = new int[2][2];
	private double caseOnlypValue;
	
	private double[][] expectedControls = new double[2][2];
	private int[][] observedControls = new int[2][2];
	private double caseControlpValue;
		
	public Interaction(String entry) {
		StringTokenizer st = new StringTokenizer(entry,"\t");
		
		mapfileIndex = new int[interactionArity];
		mode = new String[interactionArity];
		chromosome = new int[interactionArity];
		snpRSID = new String[interactionArity];
		cmdistance = new double[interactionArity];
		bpdistance = new long[interactionArity];
		
		StringTokenizer snp;
		for(int i=0; i<interactionArity; i++) {
			snp = new StringTokenizer(st.nextToken(),",");
			mapfileIndex[i] = Integer.parseInt ( snp.nextToken() );
			mode[i] = snp.nextToken();
			chromosome[i] = Integer.parseInt( snp.nextToken() );
			snpRSID[i] = snp.nextToken();
			cmdistance[i] = Double.parseDouble( snp.nextToken() );
			bpdistance[i] = Long.parseLong( snp.nextToken() );
		}
		
		StringTokenizer carrierCount; 
		
		carrierCount = new StringTokenizer(st.nextToken(),"/");
		expectedCases[0][0] = Double.parseDouble(carrierCount.nextToken());
		expectedCases[0][1] = Double.parseDouble(carrierCount.nextToken());
		expectedCases[1][0] = Double.parseDouble(carrierCount.nextToken());
		expectedCases[1][1] = Double.parseDouble(carrierCount.nextToken());
		
		carrierCount = new StringTokenizer(st.nextToken(),"/");
		observedCases[0][0] = Integer.parseInt(carrierCount.nextToken());		
		observedCases[0][1] = Integer.parseInt(carrierCount.nextToken());		
		observedCases[1][0] = Integer.parseInt(carrierCount.nextToken());		
		observedCases[1][1] = Integer.parseInt(carrierCount.nextToken());		
		
		caseOnlypValue = Double.parseDouble(st.nextToken());
		
		carrierCount = new StringTokenizer(st.nextToken(),"/");
		expectedControls[0][0] = Double.parseDouble(carrierCount.nextToken());
		expectedControls[0][1] = Double.parseDouble(carrierCount.nextToken());
		expectedControls[1][0] = Double.parseDouble(carrierCount.nextToken());
		expectedControls[1][1] = Double.parseDouble(carrierCount.nextToken());
		
		carrierCount = new StringTokenizer(st.nextToken(),"/");
		observedControls[0][0] = Integer.parseInt(carrierCount.nextToken());		
		observedControls[0][1] = Integer.parseInt(carrierCount.nextToken());		
		observedControls[1][0] = Integer.parseInt(carrierCount.nextToken());		
		observedControls[1][1] = Integer.parseInt(carrierCount.nextToken());	
		
		caseControlpValue = Double.parseDouble(st.nextToken());
	}
	
	public String[] getSnpRSID() {
		return snpRSID;
	}

	public int[] getMapfileIndex() {
		return mapfileIndex;
	}

	public String[] getMode() {
		return mode;
	}

	public int[] getChromosome() {
		return chromosome;
	}

	public double[] getCmdistance() {
		return cmdistance;
	}

	public long[] getBpdistance() {
		return bpdistance;
	}

	public int getInteractionArity() {
		return interactionArity;
	}
	
	public double[][] getExpectedCases() {
		return expectedCases;
	}
 	
	public int[][] getObservedCases() {
		return observedCases;
	}
	
	public double getCaseOnlyPval() {
		return caseOnlypValue;
	}
	
	public double[][] getExpectedControls() {
		return expectedControls;
	}
	
	public int[][] getObservedControls() {
		return observedCases;
	}
	
	public double getCaseVsControlPval() {
		return caseControlpValue;
	}
	
}
